home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_100 / 198_02 / main.c < prev    next >
Text File  |  1990-01-21  |  56KB  |  1,612 lines

  1. /*
  2.  *    MicroEMACS 3.9
  3.  *             written by Dave G. Conroy.
  4.  *            substatially modified by Daniel M. Lawrence
  5.  *
  6.  *    (C)opyright 1987 by Daniel M. Lawrence
  7.  *    MicroEMACS 3.9 can be copied and distributed freely for any
  8.  *    non-commercial purposes. MicroEMACS 3.9 can only be incorporated
  9.  *    into commercial software with the permission of the current author.
  10.  *
  11.  * This file contains the main driving routine, and some keyboard processing
  12.  * code, for the MicroEMACS screen editor.
  13.  *
  14.  * REVISION HISTORY:
  15.  *
  16.  * 1.0  Steve Wilhite, 30-Nov-85
  17.  *      - Removed the old LK201 and VT100 logic. Added code to support the
  18.  *        DEC Rainbow keyboard (which is a LK201 layout) using the the Level
  19.  *        1 Console In ROM INT. See "rainbow.h" for the function key defs
  20.  *      Steve Wilhite, 1-Dec-85
  21.  *      - massive cleanup on code in display.c and search.c
  22.  *
  23.  * 2.0  George Jones, 12-Dec-85
  24.  *      - Ported to Amiga.
  25.  *
  26.  * 3.0  Daniel Lawrence, 29-Dec-85
  27.  *      - rebound keys/added new fast buffered I/O for AMIGA
  28.  *    - added META- repeat commands
  29.  *    - added reposition default to center screen (yeah!)
  30.  *    - changed exit with modified buffers message
  31.  *    - made filesave tell us what it is doing
  32.  *    - changed search string entry to terminate with <ESC>
  33.  *      so we can use <NL> in search/replace strings
  34.  *    - updated version number in mode line to 3.0
  35.  *    12-Jan-86
  36.  *    - Added code to reconize the search/replace functions
  37.  *    - Added code to perform search/replace & query functions
  38.  *    14-Jan-86
  39.  *    - moved search logic to separate function in search.c
  40.  *    - added replace and query replace functions
  41.  *    - separated out control key expansions to be used by others in search.c
  42.  *    15-Jan-86
  43.  *    - changed "visiting" to finding
  44.  *    - changed yes/no responses to not need return
  45.  *    - cleaned up various messages
  46.  *    16-jan-86
  47.  *    - fixed spurious spawn message in MSDOS
  48.  *    - added ^X-S synonym to save command
  49.  *    - moved escape to shell to ^X-C
  50.  *    21-jan-86
  51.  *    - added code to suspend shell under BSD
  52.  *    22-jan-86
  53.  *    - added function key support (SPEC) under MSDOS
  54.  *    - Abort now prints [Aborted] on message line
  55.  *    23-jan-86
  56.  *    - Added modes and commands to set/unset them
  57.  *    24-jan-86
  58.  *    - Added Goto Line command
  59.  *    - added Rename Buffer command
  60.  *    28-jan-86
  61.  *    - added goto beginning and end of paragraph commands (META-P/META-N)
  62.  *    - re-wrote kdelete to use realloc. Gained MUCH speed here when
  63.  *      doing large wipes on both UNIX and MSDOS. Changed kill buffer
  64.  *      allocation block size from 256 bytes to 1 k
  65.  *    29-jan-86
  66.  *    - moved extern function declarations to efunc.h
  67.  *    - made name[] name binding table
  68.  *    30-jan-86
  69.  *    - fixed Previous/Next paragraph command not to wrap around EOF
  70.  *    - added Fill Paragraph command (META-Q)
  71.  *    4-feb-86
  72.  *    - added code to properly display long lines, scrolling them right
  73.  *      to left
  74.  *    5-feb-85
  75.  *    - rewrote code to right/left scroll...much better
  76.  *    - added shifted arrow keys on IBMPC
  77.  *    6-feb-85
  78.  *    - add option to allow forward-word to jump to beginning of
  79.  *      next word instead of end of current one. This is different from
  80.  *      other emacs' but can be configured off in estruct.h
  81.  *    - added VIEW mode to allow a buffer to be read only
  82.  *       (-v switch on command line will activate this)
  83.  *    - changed quick exit to write out ALL changed buffers!!!
  84.  *      MAKE SURE YOU KNOW THIS WHEN META-Zing
  85.  *    10-feb-86
  86.  *    - added handling of lines longer than allowed on file read in
  87.  *      (they wrap on additional lines)
  88.  *    - made having space clear the message line and NOT insert itself
  89.  *      a configuration option in ed.h
  90.  *    11-feb-86
  91.  *    - added Describe-command and Help commands.
  92.  *    13-feb-86
  93.  *    - added View file command (^X ^V) and finished HELP command
  94.  *    14-feb-86
  95.  *    - added option to let main loop skip update if type ahead commands
  96.  *       are queued up
  97.  *    16-feb-86
  98.  *    - added Insert File command
  99.  *    17-feb-86
  100.  *    - added scroll next window up/down commands
  101.  *    18-feb-86
  102.  *    - added CMODE indentation
  103.  *    - re-arranged header files to standardize extern and global
  104.  *      definitions
  105.  *    - changed version number to 3.2
  106.  *    - added numeric arguments to search, reverse search and
  107.  *      search and replace
  108.  *    24-feb-86
  109.  *    - added Bind To Key function (^C for now) to allow the user
  110.  *      to change his command keys
  111.  *    - added Unbind key function (M-^C for now)
  112.  *    - added execute named command to execute unbound commands (M-X)
  113.  *    - added describe bindings command (not bound)
  114.  *    - changed version number to 3.3
  115.  *    25-feb-86
  116.  *    - scrapped CERROR mode (too many compilers)
  117.  *    - added EXACT mode for case sensitive searchers
  118.  *    26-feb-86
  119.  *    - added command completion on execute named command and
  120.  *      all routined grabbing a command name
  121.  *    - adding execute-command-line command and its support functions
  122.  *      (in preparation for sourcing files)
  123.  *    - added Execute Buffer command
  124.  *    27-feb-86
  125.  *    - added execute(source) file command and added code to automatically
  126.  *      execute emacs.rc (or .emacsrc on UNIX) before initial read in
  127.  *    - changed version number to 3.4
  128.  *    4-mar-86
  129.  *    - changed word delete to be consistant with word move (it gets
  130.  *      rid of the inter word space now) This is configurable with the
  131.  *      NFWORD symbol in estruct.h
  132.  *    - added B_ACTIVE entry to the buffer table. Let emacs read multiple
  133.  *      file names from the command line and only read them in as needed
  134.  *    5-mar-85
  135.  *    - rewrote command line parser to get rid of my patchy code
  136.  *    - changed version number to 3.5
  137.  *    1-apr-86
  138.  *    - added support for Aztec C 3.20e under MSDOS
  139.  *    - fixed bug in mlwrite on ADM3's and their ilk under V7
  140.  *    - added insertion of pounds in column one under CMODE
  141.  *    - changed version number to 3.6
  142.  *    3-apr-86
  143.  *    - added next-buffer command (^X-X)
  144.  *    5-apr-86
  145.  *    - added kill paragraph command (M-^W)
  146.  *    - changed fill-paragraph to leave 2 spaces after a period at the
  147.  *      end of a word.
  148.  *    - added OVERWRITE mode
  149.  *    7-apr-86
  150.  *    - fixed overwrite mode to handle tabs
  151.  *    8-apr-86
  152.  *    - added add/delete global mode (<ESC>M & <ESC> ^M) commands
  153.  *    9-apr-86
  154.  *    - added insert space command
  155.  *    - moved bindings around        ^C    insert space
  156.  *                    M-K    bind-to-key
  157.  *                    INSERT    insert space
  158.  *                    DELETE    forwdel
  159.  *    - added hunt forward and hunt reverse commands
  160.  *    10-apr-86
  161.  *    - fixed bug in DOBUF with non-terminated command string
  162.  *    15-apr-86
  163.  *    - fixed tab expansion bug in DISPLAY which hung the AMIGA
  164.  *      (sent in by Dawn Banks)
  165.  *    - fixed curcol problen if forwline/backline during keyboard
  166.  *      macro execution (sent in by Ernst Christen)
  167.  *    - added AMIGA function/cursor key support
  168.  *    - fixed nonterminating <NL> replacement bug
  169.  *    - fixed word wrapping problems
  170.  *    16-apr-86
  171.  *    - updated documentation and froze development for 3.6 net release
  172.  *    23-apr-86    version 3.6a
  173.  *    - added foreground and background colors. Setable with the
  174.  *      add mode commands for the moment
  175.  *    24-apr-86
  176.  *    - added command to pipe CLI output to a buffer
  177.  *    25-apr-86
  178.  *    - added Dana Hoggatt's code to replace Lattice's sick system()
  179.  *      function. Now we no longer care what the switchar is.
  180.  *    - cleaned up the positioning on several of the spawing commands
  181.  *    26-apr-86
  182.  *    - added an output flush in vttidy(). Unix really appreciates this.
  183.  *    - added filter-buffer (^X#) command to send a buffer through
  184.  *      a DOS filter
  185.  *    - made automatic CMODE on .c and .h file compilation dependant
  186.  *      in estruct.h
  187.  *    1-may-86
  188.  *    - optimized some code in update(). It certainly need a lot more.
  189.  *    - added Aztec profiling capabilities. These are conditional on
  190.  *      the APROF symbol in estruct.h
  191.  *    2-may-86
  192.  *    - added (u)ndo command in query-replace. undoes last repalce.
  193.  *    6-may-86
  194.  *    - re-organized and wrote the update() function in display.c
  195.  *      Now my color hacks are in the right places and the code can be
  196.  *      understood.
  197.  *    [Released version 3.6f for BETA test sites]
  198.  *    8-may-86
  199.  *    - fixed bug in new display routine to wrap cursor on extended
  200.  *      lines at the right time
  201.  *    - modified the buffer-position command to give reasonable info
  202.  *    9-may-86
  203.  *    - improved